package com.roc.web.action;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class OperatorAuthSearchCondition extends BaseSearchCondition {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7551009930706342593L;
	
	private String accountNo;
	private String  minDate;//提交时间
	private String  maxDate;//提交时间 
	private String realName;
	private String idCard;

	public String getMinDate() {
		return minDate;
	}

	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	public String getMaxDate() {
		return maxDate;
	}

	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}

	public String getAccountNo() {
		return accountNo;
	}

	public void setAccountNo(String accountNo) {
		this.accountNo = accountNo;
	}

	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		
		if(Constance.isNotEmpty(accountNo)){ 
			filedBeanList.add(new WhereHQLFieldBean("A.ACCOUNT_NO", accountNo.trim(), "=", false));
		}
		if(Constance.isNotEmpty(realName)){ 
			filedBeanList.add(new WhereHQLFieldBean("A.name", realName.trim(), "=", false));
		}
		if(Constance.isNotEmpty(idCard)){ 
			filedBeanList.add(new WhereHQLFieldBean("A.pid", idCard.trim(), "=", false));
		}
		
		if(Constance.isNotEmpty(minDate)){
			filedBeanList.add(new WhereHQLFieldBean("TO_CHAR(A.CREATED_AT, 'YYYY-MM-DD HH24:mi:ss')",minDate,">=", false));
		}
		if(Constance.isNotEmpty(maxDate)){
			filedBeanList.add(new WhereHQLFieldBean("TO_CHAR(A.CREATED_AT, 'YYYY-MM-DD HH24:mi:ss')",maxDate,"<=", false));
		}
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer  sb= new StringBuffer();
		sb
			.append(" SELECT COUNT(1) ")
			.append(" FROM T_DYPAY_OPERATORS_DETAIL A where A.STATUS='0'");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		StringBuffer  sb= new StringBuffer();
		sb
			.append(" SELECT a.id,a.account_no as accountNo,a.name as userName,decode(a.ptype,'01','身份证','其他') as cardType,a.pid as cardNo,a.front_image,a.reverse_image,a.handle_image,a.handle_reverse_image,TO_CHAR(A.CREATED_AT, 'YYYY-MM-DD HH24:mi:ss'),ext1,ext2 ")
			.append(" FROM T_DYPAY_OPERATORS_DETAIL A where A.STATUS='0'");
		return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {
		return " ORDER BY A.CREATED_AT desc";
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getIdCard() {
		return idCard;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}
	
	

}
